﻿///////////////////////////////////////////////////////////////////////////////////////////////
// System.Text.Parsing - © 2011 Sebastien Pellizzari
// Released under the MIT License (http://www.opensource.org/licenses/mit-license.php)
///////////////////////////////////////////////////////////////////////////////////////////////

namespace System.Text.Parsing
{
    /// <summary>Represents a property in a grammar.</summary>
    public sealed class GrammarProperty
    {
        private readonly GrammarTextValue _name;            // Property name.
        private readonly GrammarTextValue _value;           // Property value.
        private readonly GrammarSourceRange _sourceInfo;    // Property source info.

        //-----------------------------------------------------------------------
        //     Properties
        //-----------------------------------------------------------------------

        /// <summary>Gets the name of the property.</summary>
        public GrammarTextValue Name { get { return _name; } }
        /// <summary>Gets the value of the property, if it has one.</summary>
        public GrammarTextValue Value { get { return _value; } }
        /// <summary>Gets the property source information.</summary>
        public GrammarSourceRange SourceInfo { get { return _sourceInfo; } }

        //-----------------------------------------------------------------------
        //     Constructors
        //-----------------------------------------------------------------------

        /// <summary>Initializes an instance of the <see cref="GrammarProperty"/> class.</summary>
        /// <param name="name">The name of the property.</param>
        /// <param name="value">The value of the property.</param>
        /// <param name="source">The property source information.</param>
        public GrammarProperty(GrammarTextValue name, GrammarTextValue value, GrammarSourceRange source)
        {
            if (name.Text == null) throw new ArgumentNullException("name.Text");
            _name = name;
            _value = value;
            _sourceInfo = source;
        }
    }
}
